import json

import requests
import pytest

def dljson():
    with open("user.json", "r", encoding="utf-8") as f:
        data = json.load(f)
        print(data)
        return data
class Test_zhpt():
    token = ""
    def setup_mothed(self):
        print("用例开始执行")

    def teardown_mothed(self):
        print("用例执行结束")

    def test_login(self):
        url = "http://10.59.9.21/api/user/login"
        data = {"username":"admin","password":"8i4De25KlVQVwqTDgTNGqw=="}
        res = requests.post(url=url,json=data)
        Test_zhpt.token = res.json()["token"]
        print("登录",res.json())

    @pytest.mark.parametrize("data1",dljson())
    def test_xzdls(self,data1):
        url = "http://10.59.9.21/api/user/register"
        data = {"username":data1.get("username"),"password":"VNL9/mV/NWDxlNtPxKWdaOAJ6KDXt2ypRjCu7ZA9C1k=","checkPwd":"VNL9/mV/NWDxlNtPxKWdaOAJ6KDXt2ypRjCu7ZA9C1k=","a_id":data1.get("id"),"dtype":2,"phone":"21212121","deadline":"2025-12-30"}
        head = {"token":Test_zhpt.token,"uid":"1"}
        res = requests.post(url=url,json=data,headers=head)
        print(res.json())


